#pragma once

#include <iostream>
#include <string>
#include <ctime>
#include <iomanip>

#define NORMAL 1
#define WARNING 2
#define DEBUG 3
#define FATAL 4

// 在宏参当中带#可以将宏名称转字符串
#define LOG(LEVEL, MESSAGE) log(#LEVEL, MESSAGE, __FILE__, __LINE__)

std::time_t current_time = std::time(nullptr);
std::tm* localTime = std::localtime(&current_time);

void log(std::string level, std::string messgae, std::string file, int line)
{
    char buffer[80];
    std::strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", localTime);

    std::cout << "[" << level << "]" << "[" << buffer
              << "]" << "[" << messgae << "]" << "[" << file << " : " << line << "]" << std::endl;
}